using System;
using System.Collections.Generic;
using System.Linq;
using CSI.Directory.Core.Model;
using CSI.Directory.Core.Repositories;

namespace CSI.Directory.Repo
{
    public class UserRepository : RepositoryBase, IUserRepository
    {
        public User GetUserByName(string username)
        {
            return GetByName<User>(username);
        }

        

        public IList<User> GetAllContentManagers()
        {
            return repo.Find<User>(t => t.Roles != string.Empty);
        }

        public int CreateUser(User u)
        {
            repo.Add(u);
            return u.Id;
        }
        public int DeleteUser(User u)
        {
            return Delete<User>(u.Id);
        }

        public int RoleContentManager(User u)
        {
            return repo.Update(u);
        }


       

        public User GetUserByEmail(string email)
        {
            return repo.Single<User>(t => t.Email == email);
        }

       
        public IList<User> GetAllUsers()
        {
            return repo.All<User>().ToList();
        }

       

      
        public void UpdateUser(User user)
        {
            repo.Update(user);
        }

       

    }
}